package com.rong.shop.service.impl;

import com.rong.shop.mapper.ProductMapper;
import com.rong.shop.pojo.Product;
import com.rong.shop.service.IProductService;
import com.rong.shop.service.ex.NotFoundProductException;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;

@Service
public class ProductServiceImpl implements IProductService {

    @Autowired
    private ProductMapper productMapper;

    @Override
    public List<Product> findHot() {
        List<Product> hots = productMapper.findHot();
        return hots;
    }

    @Override
    public Product findById(Integer id) {
        Product product = productMapper.findById(id);
        System.out.println(product);
        if(product == null){
            throw new NotFoundProductException("没有找到该商品");
        }
        return product;
    }


}
